<%--
  Created by IntelliJ IDEA.
  User: xh
  Date: 2020/2/13
  Time: 13:13
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>我的收藏 - 技术栈 - Java程序员成长平台</title>
    <meta name="keywords" content="">
    <meta name="description" content>
    <link rel="stylesheet" href="${APP_PATH}/vendor/layui-v2.4.5/layui/css/layui.css">
    <link rel="stylesheet" href="${APP_PATH}/css/common.css">
    <link rel="stylesheet" href="${APP_PATH}/css/header.css">
    <link rel="stylesheet" href="${APP_PATH}/css/footer.css">
    <link rel="stylesheet" href="${APP_PATH}/css/favorite.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<jsp:include page="head.jsp"></jsp:include>

<div class="layui-main g-main">
    <div class="layui-row">
        <div class="layui-col-xs12">
            <blockquote class="layui-elem-quote">
                收藏文章：<span class="layui-badge-rim badge-number">${requestScope.BlogTotal}篇</span>，
                收藏问题：<span class="layui-badge-rim badge-number">${requestScope.QuestionTotal}个</span>
            </blockquote>
            <div class="layui-tab layui-tab-brief l-favorite-tab" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title l-favorite-list-title">
                    <li class="layui-this" id="blog">文章</li>
                    <li id="question">问题</li>
                </ul>
                <div class="layui-tab-content l-favorite-list-content">
                    <div class="layui-tab-item layui-show">
                        <c:forEach items="${requestScope.page1.datas}" var="Bcollection" varStatus="status">
                            <div class="layui-row">
                                <div class="layui-col-xs10 l-favorite">
                                    <div class="title layui-elip">
                                        <a href="${APP_PATH}/blog/toBlog-detail?id=${Bcollection.id}" title="${Bcollection.title}">
                                            <span class="layui-badge layui-bg-cyan c-mr3">文</span>${Bcollection.title}
                                        </a>
                                    </div>
                                </div>
                                <div class="layui-col-xs2">
                                    <div class="delete-favorite">
                                            <button class="layui-btn layui-btn-sm layui-btn-danger layui-icon layui-icon-delete" onclick="deleteBCollection(${Bcollection.id})">取消收藏</button>
                                    </div>
                                </div>
                            </div>
                        </c:forEach>


                    </div>
                    <div class="layui-tab-item">
                        <c:forEach items="${requestScope.page2.datas}" var="Qcollection" varStatus="status">
                        <div class="layui-row">
                            <div class="layui-col-xs10 l-favorite">
                                <div class="title layui-elip">
                                    <a href="${APP_PATH}/question/toQuestion-detail?id=${Qcollection.id}" title="${Qcollection.title}">
                                        <span class="layui-badge layui-bg-cyan c-mr3">问</span>${Qcollection.title}
                                    </a>
                                </div>
                            </div>
                            <div class="layui-col-xs2">
                                <div class="delete-favorite">
                                        <button class="layui-btn layui-btn-sm layui-btn-danger layui-icon layui-icon-delete" onclick="deleteQCollection(${Qcollection.id})">取消收藏</button>
                                </div>
                            </div>
                        </div>
                    </c:forEach>

                    </div>
                </div>
            </div>

            <div class="page layui-show" id="page1" >

                <div id="layui-laypage" class="layui-box layui-laypage layui-laypage-default">
                    <c:if test="${requestScope.page1.pageNo > 1}">
                        <a class="layui-laypage-prev" href="${APP_PATH}/toCollection?pageNo1=${requestScope.page1.pageNo - 1}&pageNo2=${requestScope.page2.pageNo}&userId=${sessionScope.user.id}" data-page="1">上一页</a>
                    </c:if>
                    <c:if test="${requestScope.page1.pageNo <= 1}">
                        <a class="layui-laypage-prev layui-disabled" href="#" data-page="0">上一页</a>
                    </c:if>

                    <c:forEach begin="1" end="${requestScope.page1.pageTotal}" var="i" step="1">
                        <c:if test="${i == requestScope.page1.pageNo}">
                <span class="layui-laypage-curr">
            <em class="layui-laypage-em"></em>
            <em>${i}</em>
             </span>
                        </c:if>
                        <c:if test="${i != requestScope.page1.pageNo}">
                            <a href="${APP_PATH}/toCollection?pageNo1=${i}&pageNo2=${requestScope.page2.pageNo}&userId=${sessionScope.user.id}" data-page="${i}">${i}</a>
                        </c:if>
                    </c:forEach>

                    <c:if test="${requestScope.page1.pageNo < requestScope.page1.pageTotal}">
                        <a class="layui-laypage-next" href="${APP_PATH}/toCollection?pageNo1=${requestScope.page1.pageNo + 1}&pageNo2=${requestScope.page2.pageNo}&userId=${sessionScope.user.id}" >下一页</a>
                    </c:if>
                    <c:if test="${requestScope.page1.pageNo >= requestScope.page1.pageTotal}">
                        <a class="layui-laypage-next layui-disabled" href="#" >下一页</a>
                    </c:if>
                </div>

            </div>
            <div class="page" id="page2" >

                <div id="layui-laypage" class="layui-box layui-laypage layui-laypage-default">
                    <c:if test="${requestScope.page2.pageNo > 1}">
                        <a class="layui-laypage-prev" href="${APP_PATH}/toCollection?pageNo1=${requestScope.page1.pageNo}&pageNo2=${requestScope.page2.pageNo - 1}&userId=${sessionScope.user.id}" data-page="1">上一页</a>
                    </c:if>
                    <c:if test="${requestScope.page2.pageNo <= 1}">
                        <a class="layui-laypage-prev layui-disabled" href="#" data-page="0">上一页</a>
                    </c:if>

                    <c:forEach begin="1" end="${requestScope.page2.pageTotal}" var="i" step="1">
                        <c:if test="${i == requestScope.page2.pageNo}">
                <span class="layui-laypage-curr">
            <em class="layui-laypage-em"></em>
            <em>${i}</em>
             </span>
                        </c:if>
                        <c:if test="${i != requestScope.page2.pageNo}">
                            <a href="${APP_PATH}/toCollection?pageNo1=${requestScope.page1.pageNo}&pageNo2=${i}&userId=${sessionScope.user.id}" data-page="${i}">${i}</a>
                        </c:if>
                    </c:forEach>

                    <c:if test="${requestScope.page2.pageNo < requestScope.page2.pageTotal}">
                        <a class="layui-laypage-next" href="${APP_PATH}/toCollection?pageNo1=${requestScope.page1.pageNo }&pageNo2=${requestScope.page2.pageNo + 1}&userId=${sessionScope.user.id}" >下一页</a>
                    </c:if>
                    <c:if test="${requestScope.page2.pageNo >= requestScope.page2.pageTotal}">
                        <a class="layui-laypage-next layui-disabled" href="#" >下一页</a>
                    </c:if>
                </div>

            </div>
        </div>
    </div>
</div>

<div class="g-footer layui-clear">
    <hr>
    <div>Copyright ©2018 技术栈(jishuzhan.club), All Rights Reserved.</div>
    <div>渝ICP备13001123号-2</div>
</div>

<script src="${APP_PATH}/vendor/holder.min.js"></script>
<script src="${APP_PATH}/vendor/layui-v2.4.5/layui/layui.js"></script>
<script src="${APP_PATH}/js/common.js"></script>
<%--<script src="${APP_PATH}/js/favorite.js"></script>--%>
<script src="${APP_PATH}/jquery/jquery-2.1.1.min.js"></script>
<script>
    $(function () {
        $("#blog").click(function () {
                alert("cg")
        });

        $("#question").click(function () {
                alert("cg")
        })


    });

    function deleteBCollection(id) {
        layer.confirm("您确定要取消收藏吗！", {icon: 3, title: '提示'}, function (cindex) {

            $.ajax({
                url: "${APP_PATH}/blog/deleteBCollection",
                method: "POST",
                data: id,
                success:function () {
                window.location.href="${APP_PATH}/toCollection?pageNo1=1&pageNo2=1&userId=${sessionScope.user.id}";
                }
            });

            layer.close(cindex);
        }, function (cindex) {
            layer.close(cindex);
        });

    }

    function deleteQCollection(id) {
        layer.confirm("您确定要删除这条信息吗！", {icon: 3, title: '提示'}, function (cindex) {

            $.ajax({
                url: "${APP_PATH}/question/deleteQCollection",
                method: "POST",
                data: id,
                success:function () {
                    window.location.href="${APP_PATH}/toCollection?pageNo1=1&pageNo2=1&userId=${sessionScope.user.id}";
                }
            });

            layer.close(cindex);
        }, function (cindex) {
            layer.close(cindex);
        });

    }
</script>
</body>
</html>
